/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-04-26
 * Time: 23:38
 */
public class TestSolution {
    public static void main(String[] args) {
        // 创建示例链表
        ListNode node1 = new ListNode(22);
        ListNode node2 = new ListNode(28);
        ListNode node3 = new ListNode(66);
        ListNode node4 = new ListNode(88);
        node1.next = node2;
        node2.next = node3;
        node3.next = node4;

        // 初始化 Solution 对象，传入原始链表头节点
        Solution solution = new Solution(node1);

        // 打印原始链表
        System.out.println("原始链表:");
        printList(node1); // 输出: 22 28 66 88

        // 反转链表
        ListNode reversedHead = solution.reverseList();

        // 打印反转后的链表
        System.out.println("反转后的链表:");
        printList(reversedHead); // 输出: 88 66 28 22
    }

    /**
     * 辅助方法：打印链表
     * @param head 链表头节点
     */
    private static void printList(ListNode head) {
        ListNode current = head;
        while (current != null) {
            System.out.print(current.val);
            if (current.next != null) {
                System.out.print(" ");
            }
            current = current.next;
        }
        System.out.println();
    }
}
